import React, { Component } from 'react'
import { Table, Tag, Space, Card, Button, Form, Row, Col } from 'antd';
import { UserOutlined } from '@ant-design/icons';
import EventHub from '../EventHub/index'
import { EButton, EInput, ESelect, ECustomNode, ESwitch } from '../e-basic';
import { unique } from '../utils'


export class ESearchPanel extends Component {
  constructor(props) {
    super(props)
    setInterval(() => {
      console.log(this.props);
    }, 10000)
  }

  shouldComponentUpdate(nextProps, nextState) {
    console.log("nextProps:", nextProps, "nextState", nextState);
    return true
  }



  componentDidMount() {
  }

  render() {

    return <>
      <Card title="动态详情" extra={
      <Button type='primary' onClick={() => {
        EventHub.emit(unique.__RELEASE_TABLLE_LIST__, {
          time: Date.now(), 
          data: [
            {
              key: '2',
              name: '李庆峰',
              age: 25,
              address: 'London No. 1 Lake Park',
              tags: ['loser'],
            },
          ]
        })
      }}>确认
      </Button> }
        style={{ width: "96%", margin: "50px auto" }}>
        <Form {...this.props.formLayout} >
          <Row>
            {this.props.formData && this.props.formData.map((formDataItem, index) => {
              let WhoType;
              if (formDataItem.formType.includes("Input")) { WhoType = EInput }
              else if (formDataItem.formType.includes("Button")) { WhoType = EButton }
              else if (formDataItem.formType.includes("Select")) { WhoType = ESelect }
              else if (formDataItem.formType.includes("Switch")) { WhoType = ESwitch }
              else if (formDataItem.formType.includes("CustomNode")) { WhoType = formDataItem.node; return <WhoType key={index} /> }
              else { WhoType = EInput }
              return <Col lg={8} md={10} sm={10} xs={24}>
                <WhoType key={index} index={index}  params={formDataItem} superParams={this.props.formData}> </WhoType>
              </Col>
            })}
          </Row>
        </Form>
      </Card>
    </>
  }
}